package com.luxsoft.sw3.contabilidad.model;

import java.math.BigDecimal;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.validator.NotNull;
import org.hibernate.validator.Range;

import com.luxsoft.siipap.model.UserLog;
import com.luxsoft.sw3.model.AdressLog;

@Entity
@Table (name="SX_CONTABILIDAD_MENSUAL")
public class AcumuladoMensual {
	
	@Id @GeneratedValue (strategy=GenerationType.AUTO)
	@Column (name="POLIZA_ID")
	private Long id;
	
	@Version
	private int version;
	
	@ManyToOne (optional=false)
    @JoinColumn (name="CUENTA_ID", nullable=false) 
    @NotNull
	private CuentaContable cuenta;
	
	@Column(name="YEAR",nullable=false)
    @NotNull
	private int year;
	
	@Column(name="MES",nullable=false)
	@NotNull 
	@Range(min=1,max=12)
	private int mes;	
	
	@Column (name="DEBE",nullable=false,scale=6,precision=16)
	private BigDecimal debe=BigDecimal.ZERO;
	
	@Column (name="HABER",nullable=false,scale=6,precision=16)
	private BigDecimal haber=BigDecimal.ZERO;
	
	@Column (name="SALDO_INICIAL",nullable=false,scale=6,precision=16)
	@NotNull
	private BigDecimal saldoInicial=BigDecimal.ZERO;
	
	@Column (name="SALDO_FINAL",nullable=false,scale=6,precision=16)
	@NotNull
	private BigDecimal saldoFinal=BigDecimal.ZERO;
	
	@Embedded
	@AttributeOverrides({
	       @AttributeOverride(name="createUser",	column=@Column(name="CREADO_USR"	,nullable=true,insertable=true,updatable=false)),
	       @AttributeOverride(name="updateUser",	column=@Column(name="MODIFICADO_USR",nullable=true,insertable=true,updatable=true)),
	       @AttributeOverride(name="creado", 		column=@Column(name="CREADO"		,nullable=true,insertable=true,updatable=false)),
	       @AttributeOverride(name="modificado", 	column=@Column(name="MODIFICADO"	,nullable=true,insertable=true,updatable=true))
	   })
	private UserLog log=new UserLog();
	
	@Embedded
	@AttributeOverrides({
	       @AttributeOverride(name="createdIp",	column=@Column(name="CREADO_IP" ,nullable=true,insertable=true,updatable=false)),
	       @AttributeOverride(name="updatedIp",	column=@Column(name="MODIFICADO_IP",nullable=true,insertable=true,updatable=true)),
	       @AttributeOverride(name="createdMac",column=@Column(name="CREADO_MAC",nullable=true,insertable=true,updatable=false)),
	       @AttributeOverride(name="updatedMac",column=@Column(name="MODIFICADO_MAC",nullable=true,insertable=true,updatable=true))
	   })
	private AdressLog addresLog=new AdressLog();
		

}
